<?php

namespace App\Model;

use Illuminate\Database\Eloquent\Model;

class Cate extends Model
{
    //
    public function article()
    {
        return $this->hasMany('\App\Model\Article');
    }

    public function topArticle()
    {
        return $this->article()->where('is_top',1)->first();
    }
    public function listArticle()
    {
        return $this->article()->orderBy('created_at','desc')->limit(2)->get();
    }

    public function hotArticle()
    {
        return $this->article()->orderBy('answer_num','desc')->limit(3)->get();
    }


}
